package org.sgs.reddit.bot.config;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.SortedSet;
import java.util.TreeSet;

import org.apache.commons.io.IOUtils;
import org.apache.commons.io.LineIterator;


public class RedditIngester {

  private static final String FILE_PATH = RedditBotConstants.ALL_REDDITS_FILE_PATH;


  public static SortedSet<String> getAllReddits() {
    SortedSet<String> redditSet = new TreeSet<String>();
    LineIterator lineIter = null;
    try {
      lineIter = IOUtils.lineIterator(new FileReader(new File(FILE_PATH)));
    } catch (FileNotFoundException e) {
      throw new RuntimeException(e);
    }

    while (lineIter.hasNext()) {
      redditSet.add(lineIter.next());
    }

    return redditSet;
  }
}
